/* -*- c++ -*- */
/* 
 * Copyright 2013 <+YOU OR YOUR COMPANY+>.
 * 
 * This is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3, or (at your option)
 * any later version.
 * 
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this software; see the file COPYING.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street,
 * Boston, MA 02110-1301, USA.
 */

#ifndef INCLUDED_BLOCKS_PROTOCOL_SOURCE_IMPL_H
#define INCLUDED_BLOCKS_PROTOCOL_SOURCE_IMPL_H

#include <blocks/protocol_source.h>

namespace gr {
  namespace blocks {
    class protocol_phases {
    public:
    	enum phases {
            SKIP_FIRST,
            SEND_KEY,
    		SNR_ESTIMATION,
    		SEND_DATA
    	};
    };

    class protocol_source_impl : public protocol_source{
    private:
        protocol_phases::phases d_state;
        unsigned int d_symbol_counter;
        unsigned int d_snr_estimation_length;
        std::vector<int> d_snr_estimation_seq;
        std::vector<int> d_key_seq;
        unsigned int d_key_length;
        int d_skip_len;
        int d_nb_const_points;
        char d_last_sym;

    public:
      protocol_source_impl(
        int nb_constellation_points,
        int skip_len,
	    const std::vector<int> &key_seq,
	    const std::vector<int> &snr_estimation_seq);
      ~protocol_source_impl();

      // Where all the action really happens
      int work(int noutput_items,
	       gr_vector_const_void_star &input_items,
	       gr_vector_void_star &output_items);
    };

  } // namespace blocks
} // namespace gr

#endif /* INCLUDED_BLOCKS_PROTOCOL_SOURCE_IMPL_H */

